package main

import "fmt"

/*
交换两个变量的值
*/
func swap1(a, b int) {
	a, b = b, a
}
func swap2(a, b *int) {
	//a, b = b, a
	*a, *b = *b, *a
}

func swap3(a, b int) (int, int) {
	return b, a
}
func main() {
	a, b := 3, 4
	fmt.Println("交换前", a, b)

	swap1(a, b)
	fmt.Println("交换后", a, b)

	swap2(&a, &b)
	fmt.Println("交换后", a, b)

	a, b = swap3(a, b)
	fmt.Println("交换后", a, b)

	a, b = b, a
	fmt.Println("交换后", a, b)
}
